package com.googlecode.gaal.data.api;

import com.googlecode.gaal.suffix.api.IntervalTree.Interval;

/**
 * A set of lcp-intervals
 * 
 * @author akislev
 */
public interface IntervalSet<E extends Interval> extends Iterable<E> {

    /**
     * Add an interval to the set
     * 
     * @param interval
     *            - an interval to add
     * @return true - if this set did not already contain the specified interval
     */
    public boolean add(E interval);

    /**
     * Remove an interval from the set
     * 
     * @param interval
     *            - an interval to remove
     * @return true - if the set contained the specified interval
     */
    public boolean remove(E interval);

    /**
     * Check whether an interval is contained in the set
     * 
     * @param interval
     * @return true - if interval is in the set, false - otherwise
     */
    public boolean contains(E interval);

    /**
     * Add all the intervals from the other set to the current set. Intervals
     * already present in the set remain unchanged
     * 
     * @param set
     *            - a set to add
     */
    public void union(IntervalSet<E> set);

    /**
     * Removes all the intervals which are not present in the other set from the
     * current set.
     * 
     * @param set
     *            - a set to intersect with
     */
    public void intersect(IntervalSet<E> set);

}
